﻿using System;
using System.Reflection;
using TheOliver.DigitalSignage.Client.Windows;
using TheOliver.DigitalSignage.Common;

namespace TheOliver.DigitalSignage.Client.Logic
{
    public class Helper
    {
        public static Type FindInterface(Assembly assembly, Type interfaceType)
        {
            foreach (Type t in assembly.GetTypes())
            {
                if (interfaceType.IsAssignableFrom(t))
                {
                    return t;
                }
                Console.WriteLine(t.FullName + " implements " + interfaceType.FullName);
            }
            return null;
        }

        public static void ShowError(Exception exc)
        {
            if (GlobalConfiguration.SuppressErrors)
            {
                return;
            }

            ErrorWindow ew = new ErrorWindow();
            ew.Error = exc;
            ew.Show();
        }
    }
}
